<template>
  <div>
    <el-container
      :style="{ height: windHeigth + 'px' }"
      style="display: flex; flex-direction: column"
    >
      <el-header height="'100px'">
        <div class="main-pd head-logo" style="display: flex">
          <div style="flex: 2; display: flex; align-items: center">
            <el-image
              class="h-img"
              :src="logoImage"
              style="object-fit: scale-down"
            ></el-image>
            <label class="h-name">创博龙智</label>
            <label class="h-flag">质量第一客户至上</label>
          </div>
          <div
            style="
              flex: 1;
              display: flex;
              justify-content: flex-end;
              align-items: center;
            "
          >
            <div style="line-height: 0; margin-top: 0.9em; color: #999999">
              <el-badge :value="3" style="padding: 0.3em">
                <i style="font-size: 1.5em" class="el-icon-message-solid"></i>
              </el-badge>
            </div>
            <el-avatar
              style="margin-left: 4em; width: 1.8em; height: 1.8em"
              src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            ></el-avatar>
          </div>
        </div>
        <el-menu
          router
          class="main-pd"
          :default-active="$route.path"
          mode="horizontal"
          @select="handleSelect"
        >
          <el-menu-item
            v-for="item2 in item"
            :index="item2.path"
            :class="$route.path == item2.path ? 'is-active' : ''"
            :key="item2"
            >{{ item2.name }}
          </el-menu-item>
        </el-menu>
      </el-header>
      <el-main class="main-content">
        <router-view></router-view>
      </el-main>
      <el-footer height="'120px'">Footer</el-footer>
    </el-container>
  </div>
</template>

<script>
import HomePage from "./homepage/HomePage.vue"
import OnLineCourses from "./onlinecourses"
import TaskCenter from "./task"
import PointsMall from "./pointsmall"
import Questionnaire from "./questionnaire"

export default {
  name: "MainPage",
  components: {
    HomePage,
    OnLineCourses,
    TaskCenter,
    PointsMall,
    Questionnaire,
  },
  data() {
    return {
      windHeigth: 0,
      height: "",
      logoImage: require("@/assets/nav_logos.png"),
      headImage: require("@/assets/logo.png"),
      item: [
        { name: "首页", path: "/HomePage" },
        { name: "线上课程", path: "/onlinecourses" },
        { name: "任务中心", path: "/task" },
        { name: "积分商城", path: "/pointsmall" },
        { name: "问卷调查", path: "/questionnaire" },
      ],
    }
  },
  created() {
    this.windHeigth = document.documentElement.clientHeight
  },
  methods: {
    handleSelect(tab, event) {
      console.log(tab, event)
    },
    changePage() {
      // this.currentView = tabItem
    },
  },
}
</script>

<style lang="scss" scoped>
@import "src/assets/styles/common.scss";

.head-logo {
  display: flex;
  align-items: center;

  .h-img {
    width: 10em;
    height: 6em;
  }

  .h-name {
    margin-left: 0.3em;
    font-size: 2.5em;
    font-weight: bold;
  }

  .h-flag {
    margin-left: 0.9em;
    font-size: 1.5em;
    color: #666666;
  }
}

.el-header {
  color: #333;
  line-height: 6em;
  padding: 0;
}

.el-footer {
  background-color: #b3c0d1;
  color: #333;
  line-height: 120px;
  padding: 0;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: $color-grey;
  color: #333;
  text-align: center;
  line-height: 500px;
}

.main-content {
  width: 100%;
  //height: calc(100vh - 200px);
  flex: 1;
}
</style>
